package com.base;

/**
 * 位翻转
 *
 * 位翻转就是将int当做二进制，左边的位与右边的位进行互换，reverse是按位进行互换，reverseBytes是按byte进行互换
 *
 * @author zhuangqi
 * @@date 2017/3/6.
 */
public class Reverse {
    public static void main(String[] args) {
        int a = 0x12345678;
        System.out.println(Integer.toBinaryString(a));
        int r = Integer.reverse(a);
        System.out.println(Integer.toBinaryString(r));
        int rb = Integer.reverseBytes(a);
        System.out.println(Integer.toHexString(rb));
    }
}
